package yuyue

import nafos.server.OK
import nafos.server.annotation.http.Controller
import nafos.server.annotation.http.Get
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.RequestParam
import java.util.concurrent.atomic.LongAdder
import javax.validation.constraints.NotBlank

@Controller("/test")
@Validated
class TestController {
    val logadder = LongAdder()

    @Get("/test")
    fun test(@RequestParam @NotBlank id:String): Any {
        logadder.add(1)
        throw NullPointerException()
        return OK
    }

    @Get("/clear")
    fun clear(): Any {
        logadder.reset()
        return OK
    }

    @Get("/num")
    fun num(): Any {
        return logadder.sum()
    }
}